<template>
  <el-container>
    <el-header>Header</el-header>
    <el-container>
      <el-main>
        <el-row v-for="item in tableData" :key="item.id">
          <el-col :span="24">
            <div class="block">
              <el-image
                style="width: 230px; height: 178px"
                :src="src"
                :fit="contain"
              ></el-image>

              <div class="info">
                <p class="title">{{ item.title }}</p>
                <p class="detail">2室1厅|76平米|低层（共10层） 张建国</p>
                <p class="site">梅迪大道 三元-列东 徐新路47号</p>
              </div>

              <div class="money">
                <p>
                  <strong>1900</strong>
                  元/月
                </p>
              </div>
            </div>
          </el-col>
        </el-row>
      </el-main>
    </el-container>
    <el-footer
      ><!--    分页-->
      <div style="margin-top: 20px">
        <el-pagination
          background
          :current-page="params.pageNum"
          :page-size="params.pageSize"
          layout="prev, pager, next"
          @current-change="handleCurrentChange"
          :total="total"
        >
        </el-pagination></div
    ></el-footer>
  </el-container>
</template>


<script>
import Cookies from "js-cookie";
import request from "@/utils/request";
export default {
  data() {
    return {
      src: "https://cube.elemecdn.com/6/94/4d3ea53c084bad6931a56d5158a48jpeg.jpeg",
      tableData: [],
      total: 0,
      params: {
        pageNum: 1,
        pageSize: 5,
        name: "",
        phone: "",
      },
    };
  },
  created() {
    this.load();
  },
  methods: {
    load() {
      request
        .get("/house/page", {
          params: this.params,
        })
        .then((res) => {
          if (res.code === "200") {
            this.tableData = res.data.list;
            this.total = res.data.total;
            console.log(this.tableData);
          }
        });
    },
    handleCurrentChange(pageNum) {
      // 点击分页按钮触发分页
      this.params.pageNum = pageNum;
      this.load();
    },
  },
};
</script>


<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.el-header,
.el-footer {
  background-color: #b3c0d1;
  color: #333;
  text-align: center;
  line-height: 60px;
}

.el-aside {
  background-color: #d3dce6;
  color: #333;
  text-align: center;
  line-height: 200px;
}

.el-main {
  background-color: #e9eef3;
  color: #333;
  text-align: center;
  /* line-height: 160px; */
  overflow: hidden;
}

body > .el-container {
  margin-bottom: 40px;
}

.el-container:nth-child(5) .el-aside,
.el-container:nth-child(6) .el-aside {
  line-height: 260px;
}

.el-container:nth-child(7) .el-aside {
  line-height: 320px;
}
.el-row {
  /* margin-bottom: 20px; */
  background-color: #fff;
  border-bottom: 1px dashed #e6e6e6;
  cursor: pointer;
  /* width: 900px; */
  width: 920px;
  height: 220px;
  padding: 20px;
  position: relative;
  border-top: 1px dashed black;
  margin-left: -430px;
  left: 50%;
}
.el-col {
  border-radius: 4px;
}
/* .bg-purple-dark {
  background: #99a9bf;
} */
.bg-purple {
  background: #d3dce6;
}
.bg-purple-light {
  background: #e5e9f2;
}
/* .grid-content {
  border-radius: 4px;
  min-height: 36px;
} */

.block {
  position: relative;
}
.el-image {
  position: absolute;
  display: inline-block;
  overflow: hidden;
  margin-left: -50%;
  /* margin-top: -9px; */
}
.info {
  position: absolute;
  color: #797979;
  /* float: left; */
  left: 30%;
  font-size: 14px;
  overflow: hidden;
  /* padding-left: 20px; */
  width: 460px;
  text-align: left;
  font-family: Microsoft YaHei, 微软雅黑, Hiragino Sans GB, tahoma, arial,
    simhei;
}
.title {
  color: #333;
  font-size: 20px;
  font-weight: 700;
  font-family: "Microsoft YaHei";
}
.detail {
  font-size: 15px;
  font-weight: 700;
  color: #333;
}
.site {
  color: #666;
  font-size: 14px;
}
.money {
  position: absolute;
  float: right;
  width: 112px;
  right: 5%;
  margin-top: 5%;
  color: #eb5f00;
  font-size: 20px;
  font-weight: 700;
}
</style>